#pragma once

#include <pthread.h>

class Mutex{
private:
    pthread_mutex_t *pmtx_;
public:
    Mutex(pthread_mutex_t *mtx):pmtx_(mtx){}
    void lock()
    {
        pthread_mutex_lock(pmtx_);
    }
    void unlock()
    {
        pthread_mutex_unlock(pmtx_);
    }
};

class LockGuard{
private:
    Mutex mtx_;
public:
    LockGuard(pthread_mutex_t *mtx):mtx_(mtx){
        mtx_.lock();
    }
    ~LockGuard()
    {
        mtx_.unlock();
    }
};